package edu.iwyf.pms.dao;

import edu.iwyf.pms.entity.SysUser;
import org.apache.ibatis.annotations.*;

/**
 * @Author 王永飞
 * 2021/12/21 15:34
 */
public interface SysUserDao {

    @Insert("insert into sys_user(username,password,salt) values(#{username},#{password},#{salt})")
    int addUser(SysUser sysUser);

    @Select("select * from sys_user where username=#{username}")
    SysUser selectByName(String username);


    @Select("select * from sys_user where username=#{username} and password=#{password}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "username", column = "username"),
            @Result(property = "password", column = "password"),
            @Result(property = "email", column = "email"),
            @Result(property = "photourl", column = "photourl"),
            @Result(property = "islock", column = "islock"),
            @Result(property = "salt", column = "salt"),
            @Result(property = "listRole", column = "id",many = @Many(select = "edu.iwyf.pms.dao.SysRoleDao.selectedByUserId")),
    })
    SysUser selectByNameAndPass(@Param("username")String username,@Param("password") String password);
}
